<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/6/19 0019
 * Time: 10:33
 */

namespace app\currency\service;


class TimeSlotService
{
    public static $time_slot = [
        '1' => '07:00-09:00',
        '2' => '10:00-12:00',
        '3' => '13:00-15:00',
        '4' => '16:00-18:00',
        '5' => '19:00-21:00'
    ];
    public static $week = ['1','2','3','4','5','6','7'];

    /**
     * 获取服务时间
     * @param $k
     * @return mixed|string
     */
    public static function getTimeSlot($k)
    {
        if(isset(self::$time_slot[$k])){
            return self::$time_slot[$k];
        }
        return '';
    }
    public static function getTimeSlotAll()
    {
        return self::$time_slot;
    }
    public static function getCurrentTimeSlot()
    {
        $time = time();
        foreach (self::$time_slot as $key => $value) {
            list($start_time,$end_time) = explode('-',$value);
            if($time < strtotime(date('Y-m-d').' '.$start_time))
            {
                return 0;
            }
            if($time < strtotime(date('Y-m-d').' '.$end_time))
            {
                return $key;
            }
        }
    }
}